home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / xcmd / sprtxtrn.sea / Support Tools eXternals 1.2.5 / card_35834.txt < prev    next >
Text File  |  1990-11-13  |  4KB  |  81 lines

  1. -- card: 35834 from stack: in.5
  2. -- bmap block id: 10984
  3. -- flags: 0000
  4. -- background id: 3858
  5. -- name: HFSCopy
  6. ----- HyperTalk script -----
  7. on HideObjects
  8.   hide cd btn "Try It!"
  9. end HideObjects
  10.  
  11. on ShowObjects
  12.   show cd btn "Try It!"
  13. end ShowObjects
  14.  
  15.  
  16. -- part 1 (button)
  17. -- low flags: 00
  18. -- high flags: A002
  19. -- rect: left=82 top=185 right=219 bottom=175
  20. -- title width / last selected line: 0
  21. -- icon id / first selected line: 0 / 0
  22. -- text alignment: 1
  23. -- font id: 0
  24. -- text size: 12
  25. -- style flags: 8192
  26. -- line height: 16
  27. -- part name: Try it!
  28. ----- HyperTalk script -----
  29. on mouseUp
  30.   global errGlobal
  31.   put FolderPath("Choose a folder to copy please.") into sourcePath
  32.   if sourcePath = empty then exit mouseUp
  33.   put FolderPath("Choose a folder to copy into please.") into destPath
  34.   if destPath = empty then exit mouseUp
  35.  
  36.   put HFSCopy(sourcePath, destPath, "nodialog:errGlobal") into theResult
  37.   if errGlobal Γëá empty then
  38.     answer "Error: ΓÇ£" & errGlobal & "ΓÇ¥"
  39.     put empty into errGlobal
  40.   else
  41.     answer line 1 of theResult
  42.   end if
  43. end mouseUp
  44.  
  45.  
  46.  
  47.  
  48. -- part contents for background part 38
  49. ----- text -----
  50. 24/50
  51.  
  52. -- part contents for background part 20
  53. ----- text -----
  54. HFSCopy - An XFCN to copy files/folders that does a whole lot more.
  55.  
  56. HFSCopy(sourcePath, destinationPath,  ┬½"noDialog:"errorGlobal┬╗)
  57.  
  58. This XFCN will copy all files and folders from sourcePath to destinationPath.  The hidden feature of this XFCN is that the destination path does not have to exist in order for the copy to be successful.  As long as the volume name at the beginning of the path is correct, HFSCopy will automatically create all folders it needs.  Each new folder will be set to resemble the parent folder.  In other words, a new folder will have the same view, color, etc. as the parent folder.  The only difference is that the window of the new folder will be staggered down and to the right of the parent.  This is useful if you want to automatically copy selected files off of one drive while maintaining their relative heirarchy and not have to worry about empty folders.  Just create a destination folder (not necessary if you are copying to the root of a volume), set up the window so it looks nice, and call the XFCN!  I have not found any upper limit to the number of files/folders this will copy.  We have successfully used it to copy 550MB consisting of over 4,000 files and 6 levels deep.
  59.  
  60. PLEASE NOTE:  This XFCN copies folders a bit differently than most other XCMD's available now.  After testing it a bit, I think you will find this to be a more powerful implementation.  If you call HFSCopy("myHD:Folder1:","yourHD:"), all of the files in Folder1 will be put at the root level of yourHD.  A folder called "Folder1" WILL NOT be created on the destination drive.  In order to copy all source files into a folder with the same name as the source use:
  61.  
  62.   HFSCopy("MyHD:Folder1:","yourHD:FolderA:Folder1:")
  63.  
  64. This will create an exact copy of Folder1 from "MyHD" in "FolderA" of "YourHD".  By using the destination path for the CONTENTS of the source path and not the source path itself, the XFCN allows you to rename the destination folder.
  65.  
  66. Other examples:
  67.   HFSCopy("myHD:", "yourHD:")  -- clone your HD
  68.   HFSCopy("myHD:accounts","OverThere:tempFile") -- copy and rename a file
  69.  
  70. Parameter 1:  The source PATH for the copy.  Can be a path to a file or folder.
  71. Parameter 2:  The destination PATH for the copy.  Must be the same type as the source path. The destination path can be any legal path.  No one folder name can be greater than 32 characters.  If the  specified path does not exist, it will be created (i.e. if the destination is 'MyHD:Destination:somefile' and the folder 'Destination:' does not exist, it will be created.  Volumes can not be created!)  If a single file is being copied, the destination filename can be any valid filename, the copy that is made will have the filename specified in the destination.
  72.  
  73. '?' as the first parameter will return the syntax of this XCMD.
  74. '!' as the first parameter will return the copyright and version information.
  75.  
  76. 'NoDialog' can be passed as the last parameter to suppress any messages from being sent via HyperCard's answer dialog.  Error messages will be sent back in the result or in the global specified if  the last parameter is of the form: 'NoDialog:globalvarname'
  77.  
  78. Result:
  79. Line 1 will be a count of the files/folders copied.
  80. Line 2 will be an error message or empty if no error occured
  81.